<?php
$date_month = date("Y-m-d H:i:s");
$month = date('m');
$date_month = str_replace('-' . $month . '-', '-' . --$month . '-', $date_month);
$news_array =  mysql_select_array("SELECT * FROM `news` WHERE `show` = 1 AND `date`>? ORDER BY RAND() LIMIT 0,2",$date_month);
$limit = 10-count($news_array);
$products_rand = mysql_select_array("SELECT * FROM `product` WHERE `active`=1 ORDER BY RAND() LIMIT 0," . $limit);
foreach ($products_rand as $key => $value) {
    $products_rand[$key]['logo'] = mysql_value("SELECT `path` FROM `img` WHERE `logo` = 1 AND `prod_id`=?", $value['id']);
}
?>

<div class="items_prewiew_home">
    <? foreach ($products_rand as $prod): ?>
        <div class="item_container_home highlight" onclick="self.location='<?=BASE_URL;?>product.php?id=<?=$prod['id'];?>'">
            <? if ($prod['logo']): ?>
                <div class="item_conatiner_home_picture"><a href="<?=BASE_URL;?>product.php?id=<?=$prod['id'];?>"><img src="<?=BASE_URL . $prod['logo'];?>" style="width: 90px;" /></a></div>
            <?endif;?>
            <div class="item_conatiner_home_text" <?if(!$prod['logo']):?>style="width: 230px; margin: 10px;"<?endif;?>>
                <strong><?=$prod['title'];?></strong>
                <br />
                <a href="<?=BASE_URL;?>product.php?id=<?=$prod['id'];?>"><em>Подробнее...</em></a>
            </div>
        </div>
        <div class="clear"></div>
    <? endforeach; ?>
    <? foreach ($news_array as $news): ?>
        <div class="item_container_home highlight" onclick="if($('a:hover').length == 0){window.open('<?=$news['link'];?>');}">
            <? if ($news['img']): ?>
                <div class="item_conatiner_home_picture"><a href="<?=$news['link'];?>" target="_blank"><img src="<?=$news['img'];?>" style="width: 90px; max-height: 70px;" /></a></div>
            <?endif;?>
            <div class="item_conatiner_home_text" <?if(!$news['img']):?>style="width: 230px; margin: 10px;"<?endif;?>>
                <a href="<?=$news['link'];?>" style="font-size: 12px;" target="_blank"><strong><?=$news['title'];?></strong></a>
                <br />
                <a href="<?=$news['link'];?>" style="font-size: 12px;" target="_blank"><em><?=$news['title'];?></em></a>
            </div>
        </div>
        <div class="clear"></div>
    <? endforeach; ?>
</div>